#include<iostream>
using namespace std;
typedef long long LL;
int arr[10];
int main()
{
	LL ans = 0;
	for (int i = 1; i <= 8; i++) {
		cin >> arr[i];
	}
	for (int i = 1; i <= 8; i++) {
		if (arr[i] < 3) {
			continue;
		}
		if (arr[i] == 5) {
			ans += (LL)4 * i;
		}
		else {
			ans += (LL)arr[i] * i;
		}
		arr[i + 1] += arr[i] / 3;
	}
	cout << ans << endl;
	return 0;
}